home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / AIAT 1.0.1 / Headers / Index / InvertedIndex.h < prev    next >
Encoding:
Text File  |  1997-09-11  |  2.8 KB  |  98 lines  |  [TEXT/CWIE]

  1. // InvertedIndex.h
  2. //    Copyright:    © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. //// IAIndex that stores vectors.
  5.  
  6. #pragma once
  7. #ifndef InvertedIndex_h
  8. #define InvertedIndex_h
  9.  
  10. #pragma import on
  11.  
  12. #include "TermIndex.h"
  13. #include "FreqPosting.h"
  14.  
  15. #pragma IA_BEGIN_EXPORTS
  16.  
  17. const uint32        InvertedIndexType = 'Inv6';
  18.  
  19. // classes needed for private member declarations
  20. class BitArray;
  21. class UInt32Set;
  22. class InvertedTermInfo;
  23. class InvertedBlockTermInfo;
  24.  
  25. // FreqPosting Stream
  26. class FreqPS : public IAObject {
  27. public:
  28.     IA_INLINE            ~FreqPS() IA_INLINE_DEF()    // no-op dtor def
  29.     // Copys the next FreqPosting from the stream into the provided FreqPosting.
  30.     // Returns NULL at the end of the stream.
  31.     virtual bool         Next(FreqPosting* posting) = 0;
  32. };
  33.  
  34. class InvertedIndex : public virtual TermIndex {
  35. public:
  36.         InvertedIndex(IAStorage* s, IACorpus* c, IAAnalysis* a,
  37.                       uint32 t = InvertedIndexType, IABlockID r = NULL);
  38.         ~InvertedIndex();
  39.                     
  40.     // InvertedIndex-specific methods:
  41.     FreqPS*                GetFreqPostings(TermInfo* termInfo);
  42.     uint32                GetDeletedDocCount();
  43.  
  44.     // IAIndex methods we augment:
  45.     void                Initialize();
  46.     void                Open();
  47.     void                Compact();
  48.  
  49.     IADefineNarrowMethods(InvertedIndex, IAIndex);        // support for IANarrow
  50.     
  51.     virtual bool ValidateTermInfos(bool verbose);
  52.     
  53.     virtual TermInfo*            GetTermInfo(IATerm* term);
  54.  
  55. protected:
  56.     // TermIndex methods we augment to store postings:
  57.     TermInfo*            MakeTermInfo(IATerm* term, TermID id);
  58.     TermInfo*            UpdateTermInfo(TermInfo* i, FreqPosting* adds, TermFreq addCount,
  59.                                                     TermFreq delCount);
  60.     TermInfo*            MergeTermInfo(TermInfo* i, TermInfo* addTi, TermIndex* addIndex, DocID base);
  61.     uint32                MergeTermCost();
  62.     // TermIndex methods we augment to track deletions:
  63.     IABlockSize            RootSize();
  64.     void                StoreRoot(IAOutputBlock* output);
  65.     void                RestoreRoot(IAInputBlock* input);
  66.     void                Initializing();
  67.     void                DeletingDoc(DocInfo* i);
  68.     void                FinishingUpdate();
  69.     void                MergeDocIDs(TermIndex* addIndex, DocID base);
  70.  
  71.     // methods required for multiple inheritance
  72.     void                DeletingDocInternal(DocInfo* i);
  73.     void                DeletingPostings(IATerm* term, TermFreq delCount);
  74.     // delete doc clean up
  75.     void                ResetPostings(TermInfo* terminfo);
  76.     void                ResetDeletedDoc(DocInfo* docInfo);
  77.  
  78.  
  79. private:
  80.     void                UpdateTermMaxDocFreq(InvertedTermInfo* iti,
  81.                                              FreqPosting* adds, TermFreq addCount);
  82.     void                UpdatePostingBlocks(InvertedBlockTermInfo* iti,
  83.                                             FreqPosting* adds, TermFreq addCount);
  84.     void                ExpungeTermIds(UInt32Set* deletedTermIds);
  85.     InvertedTermInfo*    ExpungePostings(InvertedTermInfo* iti);
  86.     InvertedTermInfo*    ExpungePostingsBlocks(InvertedBlockTermInfo* ibti);
  87.  
  88.     IABlockID            deletedDocsRoot;
  89.     BitArray*            deletedDocs;
  90.  
  91.                         InvertedIndex(InvertedIndex&);    // don't define a copy constructor
  92. };
  93.  
  94. #pragma IA_END_EXPORTS
  95.  
  96. #pragma import reset
  97. #endif
  98.